package com.example.controller;

import com.example.exception.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HomeController {
    @GetMapping(value = "index")
    @ResponseBody
    public int index() throws Exception
    {
       int i=5/0;
//        if(i>0)
//        {
//           throw new MyException("101", "Sam 错误");
//        }
        String name=getUser(2);


        return 1;
    }

   private String getUser(int age)
   {
       if(age>0)
       {
           throw new MyException("100","没找到用户");
       }
       return "Hello";
   }
}
